<?php
include "../../public/common/config.php";
include "../../public/common/function.php";

$pos = $_POST['pos'];
$url = $_POST['url'];

//图片上传
$src = $_FILES['img']['tmp_name'];
$fname = $_FILES['img']['name'];
$a = explode('.',$fname);
$ext = array_pop($a);
$dst = '../public/uploads/'.time().mt_rand().'.'.$ext;

//如果图片上传成功，则生成缩略图
if(move_uploaded_file($src,$dst)){
	//进行图片缩放200X200
	thumb($dst,200,200);
	$img = basename($dst);
	
	$sql = "insert into advert(pos,url,img) values('{$pos}','{$url}','{$img}')";

	if(mysql_query($sql)){
		echo '<script>location="index.php"</script>';
	}
}



?>